<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />    
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>
    <header class="header header-f" style="padding-top:2rem; height:4rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            修改密码
        </div>
        <div class="header-r aui-pull-right">
        </div>
    </header>
    <div style="height:4rem;"></div>

    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        原密码：
                    </div>
                    <div class="aui-list-item-input">
                        <input type="password" placeholder="请输入原密码" id="old_pwd">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        新密码：
                    </div>
                    <div class="aui-list-item-input">
                        <input type="password" placeholder="请输入新密码" id="new_pwd">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        确认新密码：
                    </div>
                    <div class="aui-list-item-input">
                        <input type="password" placeholder="请再次输入新密码" id="new_pwd2">
                    </div>
                </div>
            </li>

        </ul> 
    </div>

    <div class="aui-content-padded">
        <div class="aui-btn aui-btn-danger aui-btn-block aui-btn-sm" onclick="change();">确认修改</div>
    </div>


</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
    apiready = function(){

    }

    function change(){

        var userid = $api.getStorage('userid');
        var authtoken = $api.getStorage('authtoken');
        var oldpwd = $api.byId('old_pwd').value;
        var newpwd = $api.byId('new_pwd').value;
        var newpwd2 = $api.byId('new_pwd2').value;

alert(oldpwd);
alert(newpwd);
alert(newpwd2);

        api.ajax({
            url: webAddress + '/a/member/Member/password',
            method: 'post',
            data: {
                values: {
                   old_password: oldpwd,
                   password: newpwd,
                   password2: newpwd2,
               },
           },
           headers: {
            TOKEN: token,
            authuid: userid,
            authtoken: authtoken,
            'Content-Type': 'application/json',
        },
    },function(ret, err){
        if (ret) {
            alert( JSON.stringify( ret ) );
            api.toast({
                msg: ret.message,
                duration: 2000,
                location: 'bottom',
                global: 'true',
            });
            // api.sendEvent({
            //     name: 'reload'
            // });
            // api.closeWin();
        } else {
            alert( JSON.stringify( err ) );
            api.toast({
                msg: err.body.message,
                duration: 2000,
                location: 'bottom',
                global: 'true',
            });
        }
    });
    }


    function openClub(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'club_win',
            url: './html/club_win.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    }

    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>